<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>万虎CMS后台管理</title>
<!-- Tell the browser to be responsive to screen width -->
<meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
<!-- Bootstrap 3.3.5 -->
<link rel="stylesheet" href="__ADMINLTE__bootstrap/css/bootstrap.min.css">

<link rel="stylesheet" href="__ADMINLTE__bootstrap/font-awesome/css/font-awesome.min.css">
<link rel="stylesheet" href="__ADMINLTE__bootstrap/ionicons/css/ionicons.min.css">
<script type="text/javascript" src="__PLUGINS__/webuploader/jquery-1.10.2.min.js"></script>

<!-- Font Awesome 
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css">
    -->
<!-- Ionicons
    <link rel="stylesheet" href="https://code.ionicframework.com/ionicons/2.0.1/css/ionicons.min.css">
    --> 
<!-- Theme style -->
<link rel="stylesheet" href="__ADMINLTE__dist/css/AdminLTE.min.css">
<link rel="stylesheet" href="__ADMINLTE__dist/css/skins/skin-blue.min.css">
<link rel="stylesheet" type="text/css" href="__PLUGINS__webuploader/webuploader.css">
<!-- test -->
<script src="__ADMINLTE__plugins/jQuery/jQuery-2.1.4.min.js"></script>
<script src="__ADMINLTE__plugins/select2/select2.full.min.js"></script>
<link rel="stylesheet" href="__ADMINLTE__plugins/select2/select2.min.css">
<!-- test end -->
<script type="text/javascript" charset="utf-8" src="__PLUGINS__ueditor/ueditor.config.js"></script>
<script type="text/javascript" charset="utf-8" src="__PLUGINS__ueditor/ueditor.all.min.js"> </script>
<script type="text/javascript" charset="utf-8" src="__PLUGINS__ueditor/lang/zh-cn/zh-cn.js"></script>
<!-- chartjs -->
<script type="text/javascript" charset="utf-8" src="__PLUGINS__chartjs/js/Chart.min.js"></script>
<!-- chartjs END-->
<!--[if lt IE 9]>
        <script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
        <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->



<style type="text/css">
.pagea{
    float: right;
}
.pagea .current{
    background:#337ab7;
    border: 1px solid #ddd;
    color: #fff;
    float: left;
    line-height: 1.42857;
    margin-left: -1px;
    padding: 6px 12px;
    position: relative;
    text-decoration: none;
}
.pagea a{
    background:#fafafa;
    border: 1px solid #ddd;
    color: #666;
    float: left;
    line-height: 1.42857;
    margin-left: -1px;
    padding: 6px 12px;
    position: relative;
    text-decoration: none;
}
.listorder{
    border: 1px solid #D0D0D0;
    height: 28px;
    margin: 0 5px 0 0;
    padding: 2px 0 2px 5px;
    border: 1px solid #d0d0d0;
    background: url("public/images/input.png") repeat-x scroll 0 0 #FFFFFF;
    font-size: 12px;
    border-radius: 3px;
}
.alink {
    color:#444;
}
</style>
</head>
<body class="hold-transition skin-blue sidebar-mini">
<div class="wrapper">

    <!-- Main Header -->
    <header class="main-header">

        <!-- Logo -->
        <a href="<?php echo U('Index/index'); ?>" class="logo">
            <span class="logo-mini"><b>W</b>MS</span>
            <span class="logo-lg"><b>Wanhu</b>CMS</span>
        </a>

        <!-- Header Navbar -->
        <nav class="navbar navbar-static-top" role="navigation">
            <!-- Sidebar toggle button-->
            <a href="#" class="sidebar-toggle" data-toggle="offcanvas" role="button">
                <span class="sr-only">Toggle navigation</span>
            </a>
            <!-- Navbar Right Menu -->
            <div class="navbar-custom-menu">

                <ul class="nav navbar-nav">

                    <li class="dropdown user user-menu">
                    <a href="<?php echo U('index/Index/index'); ?>" target="_blank">
                        <span class="hidden-xs">访问网站首页</span>
                    </a>
                    </li>
                    <!-- User Account Menu -->
                    <li class="dropdown user user-menu">
                    <?php
                    $user_info = M('user')->where('id='.session('id'))->find();
                    ?>
                    <a href="#" class="dropdown-toggle" data-toggle="dropdown">
                        <!-- <img src="__ADMINLTE__dist/img/user2-160x160.jpg" class="user-image" alt="User Image"> -->
                        <span class="hidden-xs"><?php echo $user_info['username']; ?></span>
                        <span class="hidden-xs"><?php echo $user_info['rolesin']; ?></span>
                    </a>

                    <ul class="dropdown-menu">
                        <li class="user-header">
                        <img src="__ADMINLTE__dist/img/user2-160x160.jpg" class="img-circle" alt="User Image">
                        <p>
                        Alexander Pierce - Web Developer
                        <small>Member since Nov. 2012</small>
                        </p>
                        </li>
                        <!-- Menu Footer-->
                        <li class="user-footer">
                        <div class="pull-left">
                            <a href="<?php echo U('User/edit',array('id'=>session('id'))); ?>" class="btn btn-default btn-flat">修改密码</a>
                        </div>
                        <div class="pull-right">
                            <a href="<?php echo U('Sign/out'); ?>" class="btn btn-default btn-flat">退出</a>
                        </div>
                        </li>
                    </ul>
                    </li>
                </ul>
            </div>
        </nav>
    </header>
    <aside class="main-sidebar">
        <section class="sidebar">
            <ul class="sidebar-menu">

                <li class="header"><a href="<?php echo U('Index/index'); ?>"><i class="fa fa-home"></i>系统首页</a></li>  

                <li class="<?php if(isset($active['contentAdd'])): ?>active<?php endif; ?>"><a href="<?php echo U('Content/addSliderContent'); ?>"><i class="fa fa-edit"></i><span>内容发布</span> </a></li>
                <li class="<?php if(isset($active['content'])): ?>active<?php endif; ?>"><a href="<?php echo U('Content/listindex'); ?>"><i class="fa fa-align-right"></i><span>内容管理</span> </a></li>
                <li class="<?php if(isset($active['term'])): ?>active<?php endif; ?>"><a href="<?php echo U('Term/index'); ?>"><i class="fa fa-list"></i><span>栏目管理</span></a></li>
                <li class="<?php if(isset($active['termAdd'])): ?>active<?php endif; ?>"><a href="<?php echo U('Term/addTerm'); ?>"><i class="fa fa-plus-square"></i><span>添加栏目</span></a></li> 

                <li class="treeview <?php if(isset($active['seo'])): ?>active<?php endif; ?>">
                <a href="<?php echo U('Term/index'); ?>"><i class="fa fa-line-chart"></i><span>营销</span> <i class="fa fa-angle-left pull-right"></i></a>
                <ul class="treeview-menu">
                    <li class="<?php if(isset($active['seo']['seoset'])): ?>active<?php endif; ?>"><a href="<?php echo U('Seoset/index'); ?>">SEO</a></li>
                    <li class="<?php if(isset($active['set']['online'])): ?>active<?php endif; ?>"><a href="<?php echo U('Online/index'); ?>">客服</a></li>
                </ul>
                </li>

                <?php if((APP_DEVEL)): ?>
                <li class="treeview <?php if(isset($active['model'])): ?>active<?php endif; ?>">
                <a href="<?php echo U('Term/index'); ?>"><i class="fa fa-table"></i><span>模型管理</span> <i class="fa fa-angle-left pull-right"></i></a>
                <ul class="treeview-menu">
                    <li class="<?php if(isset($active['model']['add'])): ?>active<?php endif; ?>"><a href="<?php echo U('TermModel/add'); ?>">添加模型</a></li>
                    <li class="<?php if(isset($active['model']['index'])): ?>active<?php endif; ?>"><a href="<?php echo U('TermModel/index'); ?>">模型管理</a></li>
                </ul>
                </li>
                <?php endif; ?>
                <li class="treeview <?php if(isset($active['function'])): ?>active<?php endif; ?>">
                <a href="#"><i class="fa fa-th-large"></i><span>功能模块</span> <i class="fa fa-angle-left pull-right"></i></a>
                <ul class="treeview-menu">
                    <li class="<?php if(isset($active['function']['links'])): ?>active<?php endif; ?>"><a href="<?php echo U('Links/index'); ?>">链接列表</a></li>
                    <li class="<?php if(isset($active['function']['message'])): ?>active<?php endif; ?>"><a href="<?php echo U('Message/index'); ?>">留言管理</a></li>
                </ul>
                </li>

                <li class="treeview <?php if(isset($active['extend'])): ?>active<?php endif; ?>">
                <a href="#"><i class="fa fa-th-list"></i><span>扩展功能</span> <i class="fa fa-angle-left pull-right"></i></a>
                <ul class="treeview-menu">
                    <li class="<?php if(isset($active['extend']['getDb'])): ?>active<?php endif; ?>"><a href="<?php echo U('GetDb/index',array('method'=>'index')); ?>">数据库备份</a></li>
                    <li class="<?php if(isset($active['extend']['log'])): ?>active<?php endif; ?>"><a href="<?php echo U('User/manage_log'); ?>">后台操作日志</a></li>  
                    <!-- <li><a href="<?php echo U('Index/jpgaph'); ?>">统计图</a></li>  -->
                </ul>
                </li>

                <li class="<?php if(isset($active['safe'])): ?>active<?php endif; ?>"><a href="<?php echo U('System/safe'); ?>"><i class="fa fa-area-chart"></i><span>安全与效率</span></a></li>

                <li class="treeview <?php if(isset($active['system'])): ?>active<?php endif; ?>">
                <a href="#"><i class="fa fa-gear"></i><span>系统设置</span> <i class="fa fa-angle-left pull-right"></i></a>
                <ul class="treeview-menu">

                    <li class="<?php if(isset($active['system']['option'])): ?>active<?php endif; ?>"> <a href="<?php echo U('Option/index'); ?>"><span>网站设置</span></a></li>
                    <li class="<?php if(isset($active['system']['user'])): ?>active<?php endif; ?>"><a href="<?php echo U('User/index'); ?>">管理员设置</a></li>
                    <li class="<?php if(isset($active['system']['upload'])): ?>active<?php endif; ?>"><a href="<?php echo U('System/index'); ?>">检测更新</a></li>
                    <li class="<?php if(isset($active['system']['cache'])): ?>active<?php endif; ?>"><a href="<?php echo U('System/clear_cache'); ?>">清除缓存</a></li>
                    <li class="<?php if(isset($active['system']['sitemap'])): ?>active<?php endif; ?>"><a href="<?php echo U('System/createSitemap'); ?>">生成sitemap</a></li>
                </ul>
                </li>
            </ul>
        </section>
    </aside>

    <!-- Content Wrapper. Contains page content -->
    <div class="content-wrapper">
        
        <section class="content-header">
<h1>栏目列表<small>Column List</small></h1>
<ol class="breadcrumb">
	<li><a href="<?php echo U('Index/index'); ?>">
	<i class="fa fa-dashboard"></i> 首页</a>
	</li>
	<li class="active">栏目列表</li>
</ol>
</section>
<!-- Main content -->
<section class="content">
<div class="row">
	<div class="col-xs-12">
		<div class="box">
			<div class="box-header ">
				<h3 class="box-title pad">
				<a href="<?php echo U('Term/index'); ?>" class="btn btn-primary">栏目管理</a>&nbsp;&nbsp;
				<a href="<?php echo U('Term/addTerm'); ?>" class="btn btn-primary">添加栏目</a>&nbsp;&nbsp;
				<!-- <a href="<?php echo U('Term/addTerm'); ?>" class="btn btn-primary">更新栏目缓存</a>&nbsp;&nbsp; -->
				</h3>
			</div>
			<!-- /.box-header -->
			 <form method="POST" action="<?php echo U('Term/listorder'); ?>" target="_self">
			<div class="box-body">
			   <div class="box">
			     <table class="table table-bordered table-hover">
				<!-- 列表头部 -->
				<thead>
				<tr>
					<th width="20" align="left">
						<input  name="deletec" id="deletec" type="checkbox"/>
					</th>
					<th width="40" align="left">排序</th>
					<th width="40" align="left">ID</th>
					<th width="400" align="left">栏目名称</th>
					<th width="120" align="left">栏目类型</th>
					<th width="150" align="left">模型</th>
					<th width="45" align="center">导航</th>
					<th>操作</th>
				</tr>
				</thead>
				<!-- 列表头部 -->
				<!-- 循环列表 -->
				
				<tbody style="border:none">
                <style>
                    .hasChild{
                        cursor: pointer;
                    }
                </style>
                

<?php if(is_array($parenterm)): $i = 0; $__LIST__ = $parenterm;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$data): $mod = ($i % 2 );++$i;?>

<tr id="node_<?php echo $data['id']; ?>" class="parent_id_<?php echo $data['parent_id']; ?>">
    <td width="20" align="left">
        <input  name="deletec" id="deletec" type="checkbox"/>
    </td>
    <td>
        <input name="listorder[<?php echo $data['id']; ?>]" class="listorder"  type="text" data-orderid="<?php echo $data['id']; ?>"
               value="<?php echo $data['listorder']; ?>" style="width:35px;" />
    </td>
    <td style="text-align: left"><?php echo $data['id']; ?></td>
    <td id="term_id_<?php echo $data['id']; ?>" class="<?php echo $a = D('term')->hasChild($data['id'])?'hasChild':''; ?>">
        <?php  $countpath = D('Term')->depth($data['parent_id']); $path = (count(array_unique($countpath)));         $str= '';
        for($i=0;$i<$path;$i++)
            {
                $str.="&nbsp;&nbsp;&nbsp;";
            }
        echo $str;
         echo $a ? '<img src="__ADMINLTE__dist/img/colum1nx.gif" id="term_img_'.$data["id"].'" />' : '<span style="width:12px;display: inline-block;"></span>'; echo $data['name']; ?>
    </td>
    <td>模型栏目</td>
    <td><?php if((isset($modelList[$data['model_id']]))): echo $modelList[$data['model_id']]; endif; ?></td>
    <td>&nbsp;
        <?php if(( $data['display_nav'] == 1)): ?>
        <span class="fa fa-check" style="color: #00a65a"></span>
        <?php else: ?>
        <span class="fa fa-close" style="color:#dd4b39"></span>
        <?php endif; ?>
        <!--<?php if(( $data['display_nav'] == 1)): ?>-->
        <!--显示<?php else: ?>不显示-->
        <!--<?php endif; ?>-->
    </td>
    <td>
        
        <a href="<?php echo U('Term/editTerm',array('id'=>$data['id'])); ?>" class="btn btn-primary btn-xs">修改</a>
        <a href="<?php echo U('Term/delTerm',array('id'=>$data['id'])); ?>" class="btn btn-success btn-xs">删除</a>
		<a href="<?php echo U('Term/addTerm',array('model_id'=>$data['model_id'],'parent_id'=>$data['id'])); ?>" class="btn btn-info btn-xs">添加子栏目</a>
        <!-- 新闻 -->
        <?php $find_add_term = in_array($data['id'],$result); if((!$find_add_term)): ?>
        <a href="<?php echo U('Content/index',['term_id'=>$data['id']]); ?>" class="btn btn-danger btn-xs">
            查看列表
        </a>
        <?php endif; ?>

    </td>

</tr>

<?php endforeach; endif; else: echo "" ;endif; ?>

				<tr>
					<td colspan="10" align="left">
						<input type="submit" class="btn btn-primary" value="删除" name="delete"/>&nbsp;<input type="submit" class="btn btn-primary" value="排序" />&nbsp;&nbsp;
						<span style="color: #959595;"><span class="badge bg-aqua">!</span>&nbsp;友情提示：排序方式为“从大到小”</span>
					</td>
				</tr>
				</tbody>
				
				<!-- 循环列表 END -->
				</table>

                   <script>
                       $("body").on('click', '.hasChild', function() {
                           var id = $(this).attr("id").replace("term_id_", "");
                           var childNode = $(".parent_id_" + id);

                           $("#term_img_" + id).attr("src","__ADMINLTE__dist/img/colum1nx2.gif");
                           if (childNode.html()) {
                               if(childNode.first().is(':visible')){
                                   childNode.hide();
                                   $("#term_img_" + id).attr("src","__ADMINLTE__dist/img/colum1nx.gif");
                               }else{
                                   childNode.show();
                               }
                           } else{
                               $.post('<?php echo U("Term/getchild"); ?>', {
                                   parent_id: id
                               }, function(data, textStatus, xhr) {
                                   $("#node_" + id).after(data);
                               });
                           }
                       });
                   </script>
			   </div>

			</div>
			</form>
			
		</div>
	</div>
</div>


 <script language="javascript" type="text/javascript">
 
$(document).ready(function(){


     <!-- 导航显示开始-->
	$(".display_nav").click(function(){
		   if($('.display_nav').is(':checked')) {
            	   
			$.ajax({  
			  type:"post",  
			  url:"<?php echo U('Term/displaynav'); ?>",  
			  dataType: "json",
			  data:{
			      displaynav:1, 
				  navid:$(this).val(), 
			    },  
                 });
			alert('导航显示成功');	
		 }else{
		 	$.ajax({  
			  type:"post",  
			  url:"<?php echo U('Term/displaynav'); ?>",  
			  dataType: "json",
			  data:{
			      displaynav:0, 
				  navid:$(this).val(), 

			    },  
                 });
			  alert('导航隐藏成功');	
		    }
			
			
			
	});  
	<!-- 导航显示结束-->
	
	     <!-- 置顶显示开始-->
	$(".top_ok").click(function(){
		   if($('.top_ok').is(':checked') == true) {  
			$.ajax({  
			  type:"post",  
			  url:"<?php echo U('Term/topok'); ?>",  
			  dataType: "json",
			  data:{
			      top:1, 
				  topid:$(this).val(), 
			    },				
                 });
			alert('置顶成功');	
		 }else if($('.top_ok').is(':checked') == false){
		 	$.ajax({  
			  type:"post",  
			  url:"<?php echo U('Term/topok'); ?>",  
			  dataType: "json",
			  data:{
			      top:0, 
				  topid:$(this).val(),  

			    },  
                 });
			  alert('置顶取消');	
		    }
			
			
			
	});  
	<!-- 置顶显示结束-->
	
		     <!-- 推荐显示开始-->
	$(".rec_ok").click(function(){
		   if($('.rec_ok').is(':checked')) {
            	   
			$.ajax({  
			  type:"post",  
			  url:"<?php echo U('Term/topok'); ?>",  
			  dataType: "json",
			  data:{
			      top:1, 
				  topid:$(this).val(), 
			    },  
                 });
			alert('推荐成功');	
		 }else{
		 	$.ajax({  
			  type:"post",  
			  url:"<?php echo U('Term/topok'); ?>",  
			  dataType: "json",
			  data:{
			      top:0, 
				  topid:$(this).val(),  

			    },  
                 });
			  alert('推荐取消');	
		    }
			
			
			
	});  
	<!-- 推荐显示结束-->



	
	   
});
     <!-- 排序开始-->
	$(".listorder").change(function(){
			$.ajax({  
			  type:"post",  
			  url:"<?php echo U('Term/listorder'); ?>",  
			  dataType: "json",
			  data:{
				  listorder:$(this).val(),
				  listorder_id:$(this).data("orderid"),	  
			  },  
			  success:　
			  function(data){
			   alert("修改排序成功");
			  },

		   });
		   
	});
	 <!-- 排序结束-->
</script> 
</section>
    
    </div>
    <!-- /.content-wrapper -->
    <!-- Main Footer -->
    <footer class="main-footer">
        <!-- To the right -->
        <div class="pull-right hidden-xs">
            WanhuCMS，让世界更了解你
        </div>
        <!-- Default to the left -->
        <strong>Copyright &copy; 2016 <a href="http://www.wanhunet.com" class="alink">Wanhunet</a>.All rights reserved.</strong> 
    </footer>

    <div class="control-sidebar-bg"></div>
</div>
<script src="__ADMINLTE__plugins/jQuery/jQuery-2.1.4.min.js"></script>
<script src="__ADMINLTE__plugins/select2/select2.full.min.js"></script>
<script src="__ADMINLTE__bootstrap/js/bootstrap.min.js"></script>
<script src="__ADMINLTE__dist/js/app.min.js"></script>
<script type="text/javascript" src="__PLUGINS__webuploader/webuploader.html5only.min.js"></script>
<script type="text/javascript" src="__PLUGINS__webuploader/webuploader.main.js"></script>
<script>
$(function() {
        $('.wu-example-one').createUpload('one', '<?php echo U('AjaxUploads/img'); ?>');
        $('.wu-example').createUpload('list', '<?php echo U('AjaxUploads/img'); ?>');
        $('.wu-example-file').createUpload('file', '<?php echo U('AjaxUploads/file'); ?>');
        });
</script>



</body>
</html>
